#include "addfriend.h"
#include "ui_addfriend.h"

AddFriend::AddFriend(SelfInfo info, TcpClient *tcp, QWidget *parent)
    : QWidget(parent), ui(new Ui::AddFriend), t(tcp), info(info) {
    ui->setupUi(this);
    msgBox = new QMessageBox(this);
}

AddFriend::~AddFriend() { delete ui; }

void AddFriend::on_pushButton_clicked() {
    json msg;
    msg.insert("msgid", static_cast<int>(EnMsgType::ADD_FRIEND_MSG));
    msg.insert("friendid", ui->lineEdit->text().toInt());
    msg.insert("id", info.account);
    t->SendMsg(msg);
    msgBox->setText("添加好友成功！");
    msgBox->show();
    this->close();
}
